﻿using System;
using System.Collections.Generic;
using LINQ = JLL.China.Infrastructure.Repositories.LINQ2SQL;
using JLL.China.Infrastructure.Repositories.MembserGroup;

namespace JLL.China.Infrastructure.Repositories.Member
{
    public static class MemberFactory
    {
       
        public static Model.Member FromLINQObject(LINQ.Member member)
        {
            if (member == null)
                return null;
            else
            {
                var model = new Model.Member
                {
                    ID = (int)member.Member_ID,
                    UserName = member.UserName,
                    Password = member.Password,
                    LastName = member.LastName,
                    FirstName = member.FirstName,
                    Email = member.Email,
                    Mobile = member.Mobile,
                    Group = MemberGroupFactory.FromLINQObject(member.MemberGroup)
                };
                return model;
            }
        }

        public static LINQ.Member ToLINQObject(Model.Member member)
        {
            var model = new LINQ.Member
            {
                Member_ID = member.ID,
                UserName = member.UserName,
                Password = member.Password,
                LastName = member.LastName,
                FirstName = member.FirstName,
                Email = member.Email,
                Mobile = member.Mobile,
                GroupFID = member.Group.ID
            };
            return model;
        }
    }
}
